package com.sniper.mybatis.service.impl;

import com.sniper.model.SystemConfig;
import com.sniper.mybatis.dao.BaseDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("systemConfigService")
public class SystemConfigServiceImpl extends BaseServiceImpl<SystemConfig>
        implements SystemConfigService {

    @Override
    @Resource
    public void setDao(BaseDao<SystemConfig> dao) {
        super.setDao(dao);
    }

    @Override
    public Map<String, String> mapAdminConfig(boolean auto) {
        Map<String, Object> params = new HashMap<>();
        params.put("autoload", auto);
        List<SystemConfig> configs = this.query("select", params);
        Map<String, String> map2 = new HashMap<>();
        for (SystemConfig config : configs) {
            map2.put(config.getKeyName(), config.getKeyValue());
        }
        return map2;
    }

}
